using System;
using System.Collections.Generic;

using AppPriceLive.Entities.Utils;
using AppPriceLive.Entities.Models;
using AppPriceLive.DAL;
using AppPriceLive.Common;

namespace AppPriceLive.Biz
{
	public class UsersService
	{
		/// <summary>
		/// Saves a record to the Users table.
		/// </summary>
		public virtual void Insert(UsersInfo usersInfo)
		{
			try
			{
				new UsersDAO().Insert(usersInfo);
			}
			catch (Exception ex)
			{
				Logger.Error("AppPriceLive.Biz.Users - Insert", ex);
				throw;
			}

		}

		/// <summary>
		/// Saves a record to the Users table.
		/// </summary>
		public virtual void Update(UsersInfo usersInfo)
		{
			try
			{
				new UsersDAO().Update(usersInfo);
			}
			catch (Exception ex)
			{
				Logger.Error("AppPriceLive.Biz.Users - Update", ex);
				throw;
			}

		}

		/// <summary>
		/// Delete a record from the Users table.
		/// </summary>
		public virtual void Delete(string userName)
		{
			try
			{
				new UsersDAO().Delete(userName);
			}
			catch (Exception ex)
			{
				Logger.Error("AppPriceLive.Biz.Users - Delete", ex);
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the Users table.
		/// </summary>
		public virtual UsersInfo Select(string userName)
		{
			try
			{
				return new UsersDAO().Select(userName);
			}
			catch (Exception ex)
			{
				Logger.Error("AppPriceLive.Biz.Users - Select", ex);
				throw;
			}

		}

        /// <summary>
        /// Selects a single record from the Users table.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public virtual UsersInfo UserAuth(string userName, string password)
        {
            try
            {
                return new UsersDAO().UserAuth(userName, password);
            }
            catch (Exception ex)
            {
                Logger.Error("AppPriceLive.Biz.Users - UserAuth", ex);
                throw;
            }

        }

		/// <summary>
		/// Selects all records from the Users table.
		/// </summary>
		public List<UsersInfo> SelectAll()
		{
			try
			{
				return new UsersDAO().SelectAll();
			}
			catch (Exception ex)
			{
				Logger.Error("AppPriceLive.Biz.Users - SelectAll", ex);
				throw;
			}

		}

	}
}
